#include "Bike.h"

// Default Constructor
Bike::Bike() : mName("Unknown Name"), mSize(10), mWheelDiameter(12.0) {
	/* empty */
}

Bike::Bike(const string& aName, int aSize, double aDiameter) :
mName(aName), mSize(aSize), mWheelDiameter(aDiameter) {
	if(aName == "")
		mName = "Unknown Name";
	if(aSize <= 0)
		mSize = 10;
	if(aDiameter <= 4)
		mWheelDiameter = 5.0;
}

// the const modifier tells the compiler were not going to 
// modify the calling object
string Bike::getName() const {
	return mName;
}

void Bike::setName(const string& aName) {
	mName = aName;
}

// the const modifier tells the compiler were not going to 
// modify the calling object
int Bike::getSize() const {
	return mSize;
}

void Bike::setSize(int aSize) {
	if(validSize(aSize))
		mSize = aSize;
	else
		mSize = 10;
}

// the const modifier tells the compiler were not going to 
// modify the calling object
double Bike::getWheelDiameter() const {
	return mWheelDiameter;
}

void Bike::setWheelDiameter(double aDiameter) {
	mWheelDiameter = aDiameter;
}

bool Bike::validSize(int aSize) {
	if(aSize <= 0)
		return false;
	return true;
}

// notice the const modifier at the end of the definition
// we can use the getName(), getSize, and getWheelDiameter
// because we used the const modifier in the declaration
// and definition of those functions. Without the const modifier
// in those functions, the compiler will complain. This is our
// guarantee that we won't change the data of the caller
bool Bike::equals(const Bike& aBike) const {
	return (mName == aBike.getName() &&
		mSize == aBike.getSize() &&
		mWheelDiameter == aBike.getWheelDiameter());
}

ostream& operator << (ostream& out, const Bike& aBike) {
	out << "Bike Name: " << aBike.mName << endl;
	out << "Bike Size: " << aBike.mSize << endl;
	out << "Bike Wheel Diameter: " << aBike.mWheelDiameter << endl;
	return out;
}

bool Bike::operator == (const Bike& aBike) const {
	return (mName == aBike.mName &&
		mSize == aBike.mSize &&
		mWheelDiameter == aBike.mWheelDiameter);
}

void Bike::operator = (const Bike& aBike) {
	mName = aBike.getName();
	mSize = aBike.getSize();
	mWheelDiameter = aBike.getWheelDiameter();
}
